var mysql = require("mysql");
var fs = require('fs');

function createConnection() {
    try{
        var connection = mysql.createConnection({
            host: "127.0.0.1",
            port: "3306",
            user: "root",
            password: "123456",
            database: "blog"
        });
        return connection;
    }catch(err){
        errRes(err)
    }
}

function errRes(err){
    fs.appendFile("err_log.txt", err + '\t' + new Date().toLocaleString() + '\r\n');
    return 
}

module.exports = {
    createConnection: createConnection,
    errRes: errRes,
}